package com.zackeus.sipservice.entity;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

/**
 * 抖动统计
 * @name: Jitter
 * @author: zz
 * @date: 2022/10/10
 */
public class Jitter implements Parcelable {
    /* 最小值 */
    private final int min;
    /* 最大值 */
    private final int max;
    /* 平均值 */
    private final int mean;
    /* 最终值 */
    private final int last;

    public Jitter(int min, int max, int mean, int last) {
        this.min = min;
        this.max = max;
        this.mean = mean;
        this.last = last;
    }

    public int getMax() {
        return max;
    }

    public int getMean() {
        return mean;
    }

    public int getMin() {
        return min;
    }

    public int getLast() {
        return last;
    }

    public static final Parcelable.Creator<Jitter> CREATOR =
            new Parcelable.Creator<Jitter>() {
                @Override
                public Jitter createFromParcel(final Parcel in) {
                    return new Jitter(in);
                }

                @Override
                public Jitter[] newArray(final int size) {
                    return new Jitter[size];
                }
            };

    private Jitter(Parcel in) {
        this.max = in.readInt();
        this.mean = in.readInt();
        this.min = in.readInt();
        this.last = in.readInt();
    }

    public void writeToParcel(Parcel parcel, int arg1) {
        parcel.writeInt(max);
        parcel.writeInt(mean);
        parcel.writeInt(min);
        parcel.writeInt(last);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @NonNull
    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this);
    }

}
